package com.zhang.spijdkdemo;

import com.zhang.spijdkdemo.service.PaymentService;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.ServiceLoader;

@SpringBootApplication
public class SpiJdkDemoApplication {

    public static void main(String[] args) {
        
        // load() 方法 会自动加载 META-INF/services/com.zhang.spijdkdemo.service.PaymentService 文件
        ServiceLoader<PaymentService> loaders = ServiceLoader.load(PaymentService.class);

        // TODO 增强 for 循环的底层实现依赖于 Iterable 或 Iterator 接口
        for (PaymentService loader : loaders) {  // 内部调用 iterator() 方法
            loader.pay("281729172817");
        }
    }

}
